﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace TypeScriptJson.Sample
{
	namespace Models
	{
		public class Class1
		{
			public int IntField;
			public long LongProperty { get; set; }
			public string StringField;
			public string StringProperty { get; set; }
			public DateTime DateTimeField;
			public DateTimeOffset DateTimeOffsetField;
			public Struct1 Struct1Property { get; set; }
			public Struct1? NullableStruct1Field;
		}

		public class Class2 : Class1
		{
			public JToken JTokenField;
			[JsonProperty("public_uint_field")]
			public uint UintField;

			[JsonProperty(TypeNameHandling = TypeNameHandling.Arrays)]
			public int[] IntArray;
			public IEnumerable<Struct1> Struct1Enumerable;

			public IDictionary<string, int> Dictionary1;
			public IDictionary<int, Class1> Dictionary2;
			public IDictionary<Class1, int> Dictionary3;

			//public Expression<Func<int, char>> CharGetter;
			public SomeEnum EnumField;
		}

		public struct Struct1
		{
			[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
			public string StringField;
			public int? NullableIntField;
			[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
			public Class1 PublicClass1Field;

			public GenericClass<string> GenericClassStringField;
			public GenericClass<SomeEnum> GenericClassSomeEnumField;
		}

		public class GenericClass<T> : Class1
		{
			public T TField;
			public SomeEnum EnumField;
		}

		public enum SomeEnum { One = 1, Two = 2, Three = 3 }
	}

	class Program
	{
		static void Main(string[] args)
		{
			var generator = new Generator.Generator();
			generator.Context.MapType(typeof (Models.Class2));
			generator.GenerateToSingleFile("output.d.ts");
		}
	}
}
